package com.ica.model.policy.time.utils;

import java.util.Calendar;

public abstract class TimeUtils {
	
	/**
	 * @author        Hector
	 */
	public static enum DAYS {		
		/**
		 * @uml.property  name="mONDAY"
		 * @uml.associationEnd  
		 */
		MONDAY,/**
		 * @uml.property  name="tUESDAY"
		 * @uml.associationEnd  
		 */
		TUESDAY,/**
		 * @uml.property  name="wEDNESDAY"
		 * @uml.associationEnd  
		 */
		WEDNESDAY,/**
		 * @uml.property  name="tHURSDAY"
		 * @uml.associationEnd  
		 */
		THURSDAY,/**
		 * @uml.property  name="fRIDAY"
		 * @uml.associationEnd  
		 */
		FRIDAY,/**
		 * @uml.property  name="sATURDAY"
		 * @uml.associationEnd  
		 */
		SATURDAY,/**
		 * @uml.property  name="sUNDAY"
		 * @uml.associationEnd  
		 */
		SUNDAY,/**
		 * @uml.property  name="uNKNOWN"
		 * @uml.associationEnd  
		 */
		UNKNOWN
	}
	
	public static DAYS calendarToDay(Calendar time) {	
		switch(time.get(Calendar.DAY_OF_WEEK)) {
			case Calendar.MONDAY: return DAYS.MONDAY;
			case Calendar.TUESDAY: return DAYS.TUESDAY;
			case Calendar.WEDNESDAY: return DAYS.WEDNESDAY;
			case Calendar.THURSDAY: return DAYS.THURSDAY;
			case Calendar.FRIDAY: return DAYS.FRIDAY;
			case Calendar.SATURDAY: return DAYS.SATURDAY;
			case Calendar.SUNDAY: return DAYS.SUNDAY;
			default: return DAYS.UNKNOWN;
		}
	}
	
	public static String DayToString(DAYS day) {
		switch(day) {
			case MONDAY: return "Monday";
			case TUESDAY: return "Tuesday";
			case WEDNESDAY: return "Wednesday";
			case THURSDAY: return "Thursday";
			case FRIDAY: return "Friday";
			case SATURDAY: return "Saturday";
			case SUNDAY: return "Sunday";
			default: return null;
		}
	}

	public static DAYS getNextDay(DAYS day) {
		switch(day) {
			case MONDAY: return DAYS.TUESDAY;
			case TUESDAY: return DAYS.WEDNESDAY;
			case WEDNESDAY: return DAYS.THURSDAY;
			case THURSDAY: return DAYS.FRIDAY;
			case FRIDAY: return DAYS.SATURDAY;
			case SATURDAY: return DAYS.SUNDAY;
			case SUNDAY: return DAYS.MONDAY;
			default: return DAYS.UNKNOWN;
		}
	}
	
	public static DAYS getPreviousDay(DAYS day) {
		switch(day) {
			case MONDAY: return DAYS.SUNDAY;
			case TUESDAY: return DAYS.MONDAY;
			case WEDNESDAY: return DAYS.TUESDAY;
			case THURSDAY: return DAYS.WEDNESDAY;
			case FRIDAY: return DAYS.THURSDAY;
			case SATURDAY: return DAYS.FRIDAY;
			case SUNDAY: return DAYS.SATURDAY;
			default: return DAYS.UNKNOWN;
		}
	}
}
